#include <vector>
using namespace std;
class Solution
{
public:
    int findMin(vector<int> &nums)
    {
        int left = 0, right = nums.size() - 1;
        while (left < right)
        {
            int mid = left + right >> 1;
            if (nums[mid] <= nums[right])
                right = mid;
            else
                left = mid + 1;
        }
        return nums[left];
    }
    // 先查找最大元素，然后再对其进行边界处理
    int findMin2(vector<int> &nums)
    {
        int left = 0, right = nums.size() - 1;
        while (left < right)
        {
            int mid = left + right + 1 >> 1;
            if (nums[mid] >= nums[left])
                left = mid;
            else
                right = mid - 1;
        }
        return left == nums.size() - 1 ? nums[0] : nums[left + 1];
    }
};